Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.3] build: backport NIX_ATTRS_*_FILE #12026

Merged

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Dec 8, 2024

Motivation

This was originally added in #4770 to support structured attrs in nix-shell & nix develop: the issue was that it was somewhat awkward to just write those files into a project directory, especially since it'd break in case of multiple nix-shell invocations from the same directory. Now the files are written to another, temporary location when using nix-shell/nix develop and the correct path is referenced by NIX_ATTRS_*_FILE.

In nixpkgs, it's now common to use these environment variables, however we still fall back to checking to .attrs.sh & .attrs.json since the minimum Nix version we support is 2.3.17[1] which doesn't have this change.

This however makes implementing structured attrs support more complicated than needed[2] and in fact we have a few places where the check for .attrs.sh/.attrs.json isn't made, so these only break with Nix 2.3[3].

The idea is now to

  • get this into 2.3.18
  • bump minver once again to 2.3.18 in nixpkgs
  • remove all occurrences of .attrs.sh/.attrs.json from nixpkgs.

[1] https://github.com/NixOS/nixpkgs/blob/f4bd97b8face6dc14b0ce048c20cff7e558c7be2/lib/minver.nix
[2] https://github.com/NixOS/nixpkgs/pull/357053/files#diff-791a01ef89c157eb74d9c87ab8cbc3b81e2cf082cab70b8fec3472cd75ce860dR3-R5
[3] NixOS/nixpkgs#357053 (comment)

Context

cc @wolfgangwalther @edolstra @Ericson2314


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

This was originally added in NixOS#4770 to support structured attrs in
`nix-shell` & `nix develop`: the issue was that it was somewhat awkward
to just write those files into a project directory, especially since
it'd break in case of multiple `nix-shell` invocations from the same
directory. Now the files are written to another, temporary
location when using `nix-shell`/`nix develop` and the correct path is
referenced by NIX_ATTRS_*_FILE.

In `nixpkgs`, it's now common to use these environment variables,
however we still fall back to checking to `.attrs.sh` & `.attrs.json`
since the minimum Nix version we support is 2.3.17[1] which doesn't have
this change.

This however makes implementing structured attrs support more
complicated than needed[2] and in fact we have a few places where the
check for `.attrs.sh`/`.attrs.json` isn't made, so these only break with
Nix 2.3[3].

The idea is now to

* get this into 2.3.18
* bump minver once again to 2.3.18 in nixpkgs
* remove all occurrences of `.attrs.sh`/`.attrs.json` from nixpkgs.

[1] https://github.com/NixOS/nixpkgs/blob/f4bd97b8face6dc14b0ce048c20cff7e558c7be2/lib/minver.nix
[2] https://github.com/NixOS/nixpkgs/pull/357053/files#diff-791a01ef89c157eb74d9c87ab8cbc3b81e2cf082cab70b8fec3472cd75ce860dR3-R5
[3] NixOS/nixpkgs#357053 (comment)
@Ma27 Ma27 changed the title [2.3]build: backport NIX_ATTRS_*_FILE [2.3] build: backport NIX_ATTRS_*_FILE Dec 8, 2024
@edolstra edolstra merged commit ff8cce1 into NixOS:2.3-maintenance Dec 9, 2024
7 checks passed
@Ma27 Ma27 deleted the 2.3-backport-structured-attrs-env branch December 9, 2024 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants